<template>
  <div class="serialClass" style="margin-top: 10px">
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-form-item label="波特率" prop="region">
        <el-select v-model="ruleForm.region">
          <el-option label="4800" value="4800"></el-option>
          <el-option label="5300" value="5300"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="数据位" prop="region">
        <el-select v-model="ruleForm.date1">
          <el-option label="8" value="8"></el-option>
          <el-option label="16" value="16"></el-option>
          <el-option label="32" value="32"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="校验位" prop="region">
        <el-select v-model="ruleForm.date2">
          <el-option label="8" value="8"></el-option>
          <el-option label="16" value="16"></el-option>
          <el-option label="32" value="32"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="停止位" prop="region">
        <el-select v-model="ruleForm.date2">
          <el-option label="8" value="8"></el-option>
          <el-option label="16" value="16"></el-option>
          <el-option label="32" value="32"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="流控" prop="region">
        <el-select v-model="ruleForm.date2">
          <el-option label="8" value="8"></el-option>
          <el-option label="16" value="16"></el-option>
          <el-option label="32" value="32"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')" size="small">提交</el-button>
        <el-button @click="resetForm('ruleForm')">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  data() {
    return {
      ruleForm: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: ''
      },
      rules: {
        region: [
          { required: true, message: '波特率', trigger: 'change' }
        ]
      }
    }
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('submit!');
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    }
  }
}
</script>
<style scoped>
.serialClass{
  margin-top: 10px;
}
</style>
